<template>
    <div>
        <mainTitleText>
            <span slot="account" class="account">客户管理</span>
            <span slot="accountEnglish">ENGLISII ANNOTATION</span>
        </mainTitleText>
        <div class="add">
            <form class="layui-form form1" :form1="form1">
                <div class="layui-inline">
                    <label class="layui-form-label">用户状态：</label>
                    <div class="layui-input-inline" style="width: 90px;">
                        <select
                                lay-filter="select"
                                name="type"
                                lay-verify="required"
                                lay-search>
                            <option value="">不限</option>
                            <option v-for="(item,index) in selectValues.type" :value="item">{{item}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 93px;">录入负责人：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="source"
                                lay-verify="required"
                                lay-search>
                            <option value="">录入负责人</option>
                            <option :value="item.id" v-for="(item,index) in add.datainfo">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">录入个人：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="luru"
                                lay-verify="required"
                                lay-search>
                            <option value="">录入个人</option>
                            <option :value="item.id" v-for="(item,index) in add.luru">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 92px;">接收负责人：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="receive"
                                lay-verify="required"
                                lay-search>
                            <option value="">接收负责人</option>
                            <option :value="item.id" v-for="(item,index) in add.datainfo">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">接收个人：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="jieshou"
                                lay-verify="required"
                                lay-search>
                            <option value="">接收个人</option>
                            <option :value="item.id" v-for="(item,index) in add.luru">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">意向楼盘：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="houses"
                                lay-verify="required"
                                lay-search>
                            <option value="">意向楼盘</option>
                            <option :value="item.id" v-for="(item,index) in add.building">{{item.name}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="width: 395px;">
                    <label class="layui-form-label">约访时间：</label>
                    <div class="layui-input-inline" style="width: 315px;">
                        <input
                                type="text"
                                name="date"
                                class="layui-input"
                                id="text1"
                                autocomplete="off"
                                placeholder="请选择您的约访时间">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">时间排序：</label>
                    <div class="layui-input-inline">
                        <select
                                lay-filter="select"
                                name="order"
                                lay-verify="required"
                                lay-search>
                            <option value="">时间排序</option>
                            <option :value="1">录入升序</option>
                            <option :value="2">录入降序</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <!--<button class="layui-btn layui-btn-primary" type="button" @click="join">-->
                        <!--可转接-->
                    <!--</button>-->
                    <button class="layui-btn" type="button" @click="day">备忘约访</button>
                    <button class="layui-btn" type="button" @click="Visit">到访</button>
                    <button class="layui-btn" :class="{'layui-btn-disabled':isShowBtn}" type="button">
                        <a v-show="!isShowBtn" :href="derive" style="color: #fff;" title="导出数据">导出</a>
                        <em v-show="isShowBtn" title="暂无数据">导出</em>
                    </button>
                    <button class="layui-btn layui-btn-danger" type="reset" @click="del">
                        <i class="layui-icon">&#xe640;</i>
                        清空全部
                    </button>
                </div>
            </form>
        </div>
        <div class="main">
            <!--搜索-->
            <div class="search">
                <form class="layui-form layui-form-pane form2" :form2="form2">
                    <div class="layui-form-item" >
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition1"
                                    name="source"
                                    lay-verify="required"
                                    lay-search>
                                <option value="">录入负责人</option>
                                <option :value="item.id" v-for="(item,index) in add.datainfo">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" v-show="(selectedPositionAll.selectedPosition2.length!==0)&&(showJunior===true)">
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition2"
                                    name="selectedPosition2"
                                    lay-search>
                                <!--<option value="">账户名</option>-->
                                <option
                                        :value="item.id"
                                        v-for="(item,index) in selectedPositionAll.selectedPosition2">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" v-show="(selectedPositionAll.selectedPosition3.length!==0)&&(showJunior===true)">
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition3"
                                    name="selectedPosition3"
                                    lay-search>
                                <!--<option value="">账户名</option>-->
                                <option
                                        :value="item.id"
                                        v-for="(item,index) in selectedPositionAll.selectedPosition3">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" v-show="(selectedPositionAll.selectedPosition4.length!==0)&&(showJunior===true)">
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition4"
                                    name="selectedPosition4"
                                    lay-search>
                                <!--<option value="">账户名</option>-->
                                <option
                                        :value="item.id"
                                        v-for="(item,index) in selectedPositionAll.selectedPosition4">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" v-show="(selectedPositionAll.selectedPosition5.length!==0)&&(showJunior===true)">
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition5"
                                    name="selectedPosition5"
                                    lay-search>
                                <!--<option value="">账户名</option>-->
                                <option
                                        :value="item.id"
                                        v-for="(item,index) in selectedPositionAll.selectedPosition5">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item" v-show="(selectedPositionAll.selectedPosition6.length!==0)&&(showJunior===true)">
                        <div class="layui-input-inline">
                            <select
                                    lay-filter="selectedPosition6"
                                    name="selectedPosition6"
                                    lay-search>
                                <!--<option value="">账户名</option>-->
                                <option
                                        :value="item.id"
                                        v-for="(item,index) in selectedPositionAll.selectedPosition6">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <button class="layui-btn layui-btn-sm " @click="emptyAll" v-show="showJunior===true" type="reset">清空选项</button>
                    <span>共找到{{count}}个账号</span>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <input
                                    type="text"
                                    name="text"
                                    required=""
                                    v-model="search"
                                    onkeydown="if(event.keyCode==13)return false;"
                                    @keyup.enter="searchPush"
                                    lay-verify="required"
                                    placeholder="请输入用户姓名/电话/备注"
                                    autocomplete="off"
                                    class="layui-input">
                        </div>
                        <label class="layui-form-label" @click="searchPush">
                            <i></i>
                        </label>
                    </div>
                </form>
            </div>
            <table id="table"
                   :formTable="formTable"
                   lay-filter='text'
                   style="width: 100%!important;"></table>
             <!--table工具条-->
                <script type="text/html" id="barDemo">
                  <a class="layui-btn layui-btn-xs" style="background-color:#cd1f5c " lay-event="edit"><i class="layui-icon layui-icon-edit"></i>查看</a>
                   <!--<a class="layui-btn layui-btn-xs" style="background-color: #999" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>-->
                </script>
            <!--点击查看弹出修改页面-->
            <div id="edit" class="">
                <form action="" class="layui-form" :form3="form3">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：{{values.name?values.name:'无'}}
                        </div>
                        <div class="layui-inline">
                            电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;话：{{values.telephone?values.telephone:'无'}}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：{{values.sex?values.sex:'无'}}
                        </div>
                        <div class="layui-inline">
                            意向楼盘：{{values.building?values.building:'无'}}
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;padding-right: 0">跟进状态：</label>
                            <div class="layui-input-inline" style="width: 90px;">
                                <select
                                        lay-filter="select1"
                                        id="select1"
                                        name="type"
                                        lay-search>
                                    <option v-for="(item,index) in selectValues.type" :value="item">{{item}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            约访时间：{{values.schedule?values.schedule:'无'}}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            录&nbsp;入&nbsp;&nbsp;人：{{values.account_id1?values.account_id1:'无'}}
                        </div>
                        <div class="layui-inline">
                           成交价格：{{values.price?values.price:'无'}}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            成交户型：{{values.type?values.type:'无'}}
                        </div>
                        <div class="layui-inline">
                            成交房号：{{values.number?values.number:'无'}}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            录入时间：{{values.time?values.time:'无'}}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="title">备注信息</div>
                        <div class="edit-text" v-if="!notes">
                            <p style="text-indent: 2em;padding:15px 10px 0;">{{values.notes}}</p>
                        </div>
                        <div style="text-align: center;padding:20px;color: #999;" v-else>暂无备注信息</div>
                    </div>
                    <div class="layui-form-item">
                        <div class="title">跟进信息</div>
                        <div class="edit-text" v-if="!follow_info">
                            <div
                                    class="layui-form-text"
                                    v-for="item in values.follow_info"
                            >
                                <p><span>【跟&nbsp;&nbsp;进&nbsp;人】</span><span>{{item.wang}}</span></p>
                                <p><span style="letter-spacing: 0.3px">【职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位】</span><span>{{item.role}}</span></p>
                                <p><span>【跟进信息】</span><span>{{item.content}}</span></p>
                                <p><span>【跟进时间】</span><span>{{item.date}}</span></p>
                            </div>
                        </div>
                        <div style="text-align: center;padding:20px;color: #999;" v-else>暂无跟进信息</div>
                    </div>
                    <div class="layui-form-item" style="height:auto;">
                        <div class="title">我的转介</div>
                        <div class="edit-text transfer_info" v-if="!transfer_info">
                            <div
                                    class="layui-form-text"
                                   >
                                <p><span>【接&nbsp;&nbsp;收&nbsp;人】</span><span>{{values.transfer_info.to_account_id}}</span></p>
                                <p><span style="letter-spacing: 0.3px">【职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位】</span><span>{{values.transfer_info.role}}</span></p>
                                <p><span>【接收时间】</span><span>{{values.transfer_info.date}}</span></p>
                            </div>
                        </div>
                        <div style="text-align: center;padding:20px;color: #999;" v-else>暂无转介信息</div>
                    </div>
                    <div class="layui-form-item">
                        <div class="title">我的凭证</div>
                        <img
                                v-if="!deal_info"
                                v-for="item in values.deal_info" :src="item.img"
                                @click="imgShow">
                        <p v-if="deal_info" style="text-align: center;padding:20px;color: #999;">暂无凭证</p>
                    </div>
                    <div class="layui-form-item">
                        <div class="title">到访凭证</div>
                        <img
                                v-if="!visit"
                                v-for="item in values.visit_info"
                                :src="item.content"
                                @click="imgShow">
                        <p v-if="visit" style="text-align: center;padding:20px;color: #999;">暂无凭证</p>
                    </div>
                </form>
            </div>
        </div>
    </div>
</template>
<script>
    import $ from 'jquery'
    import mainTitleText from '@/components/module/mainTitleText'
    export default {
        name: "client",
        props:['urls'],
        data(){
            return {
                isShowBtn:false,//是否禁用导出按钮
                derive:this.urls.client.search+"?simple=1",
                count:'',
                search:'',
                date:'',
                values:{},
                add:{},
                follow_info:true,
                transfer_info:true,
                deal_info:true,
                notes:false,//是否显示备注信息
                visit:false,
                selectValues:{
                    type:['星标','跟进中','失效','已定','已买'],
                    source:['录入时间','跟进时间']

                },
                showJunior:true,//显示下级
                selectedPositionAll:{//获取下级信息集合
                    selectedPosition1:[],
                    selectedPosition2:[],
                    selectedPosition3:[],
                    selectedPosition4:[],
                    selectedPosition5:[],
                    selectedPosition6:[],
                },
                isFash:false,
                searchId:''
            }
        },
        components: {
            mainTitleText: mainTitleText
        },
        created(){
            let _this = this;
            $.ajax({//获取select数据
                type:'POST',
                url:_this.urls.client.selects,
                success:function(res){
                    _this.add = res;
                    layui.use(['table','form','formSelects'],function(){//页面渲染完成重载方法
                        var table = layui.table;
                        var form = layui.form;
                        var formSelects = layui.formSelects;
                        _this.$nextTick(function(){
                            table.reload('idTest', {
                            });
                            form.render();
                            formSelects.render('function1',{
                                skin:'default',
                                create:function(){
                                    return Date.now();
                                },
                            });
                        })

                    })
                }
            });
        },
        computed: {
            form1() {
                var _this = this,
                    url = _this.urls.client.search;
                    layui.use(['form', 'jquery', 'laydate','layer'], function () {
                        var form = layui.form;
                        var laydate = layui.laydate;
                        var jointUrl='';
                        _this.$nextTick(function(){
                            laydate.render({
                                elem: '#text1'
                                , type: 'datetime'
                                , range: true
                                // ,theme: '#e11e27'
                                , format: 'yyyy/MM/dd HH:mm:ss'
                                ,done: function(value, date,endDate){
                                    _this.date = value;
                                    var serialize = $('.form1').serializeArray();
                                    for(var x = 0;x<serialize.length; x++){
                                        if(serialize[x].name === 'date'){
                                            serialize[x].value = value;
                                        }
                                        jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                                    }
                                    layui.use(['table'], function () {//搜索直接更新表格数据
                                        var table = layui.table;
                                        table.reload('idTest', {
                                            url: url,
                                            where:{
                                                type:serialize
                                            },
                                            done:function(res){
                                                if(res.data.length === 0){
                                                    _this.isShowBtn = true;
                                                }else{
                                                    _this.isShowBtn = false;
                                                }
                                            }
                                        });
                                    });
                                    _this.derive = url+"&simple=1&"+jointUrl+_this.search+'&id='+_this.searchId;
                                    jointUrl='';
                                }
                            });
                            form.on('select(select)',function(data){
                                var serialize = $('.form1').serializeArray();
                                var jointUrl='';
                                layui.use(['table'], function () {//搜索直接更新表格数据
                                    var table = layui.table;
                                    table.reload('idTest', {
                                        url: url,
                                        where:{
                                            type:serialize,
                                        },
                                        done(res){
                                            //select all change return values
                                            _this.count = res.count;
                                            if(res.data.length === 0){
                                                _this.isShowBtn = true;
                                            }else{
                                                _this.isShowBtn = false;
                                            }
                                            for(var x = 0;x<serialize.length; x++){
                                                if(serialize[x].name === 'date'){
                                                    serialize[x].value = _this.date;
                                                }
                                                jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                                            }
                                            _this.derive = url+"&simple=1&"+jointUrl+_this.search+'&id='+_this.searchId;
                                            jointUrl='';
                                        }
                                    });
                                });
                            });
                        })
                        form.render();
                    })
            },
            form2(){
                var url = this.urls.client.search;//表格加载
                var _this = this;
                layui.use(['form','table'],function(){
                    var form = layui.form;
                    var table = layui.table;
                    var jointUrl='';
                    form.on('select(selectedPosition1)',function(data){
                        if(data.value !== ''){
                            table.reload('idTest',{
                                    url: url,
                                    where:{
                                        id:data.value,
                                        type:'',
                                        yufang:'',
                                        visit: ''
                                    },done: function (res) {//渲染完成回调，获取总条目数。
                                        _this.count = res.count;
                                        if(res.number.length !== 0){
                                            _this.selectedPositionAll.selectedPosition2 = [];
                                            for(var x in res.number){
                                                _this.selectedPositionAll.selectedPosition2.push({
                                                    id:res.number[x].id,
                                                    name:res.number[x].name,
                                                });
                                                _this.selectedPositionAll.selectedPosition3 = [];
                                                _this.selectedPositionAll.selectedPosition4 = [];
                                                _this.selectedPositionAll.selectedPosition5 = [];
                                                _this.selectedPositionAll.selectedPosition6 = [];
                                                _this.$nextTick(function(){
                                                    form.render();
                                                })
                                            }
                                        }else{
                                            _this.selectedPositionAll.selectedPosition2 = [];
                                            _this.selectedPositionAll.selectedPosition3 = [];
                                            _this.selectedPositionAll.selectedPosition4 = [];
                                            _this.selectedPositionAll.selectedPosition5 = [];
                                            _this.selectedPositionAll.selectedPosition6 = [];
                                        }
                                    }
                                });
                            _this.showTool = true;
                            _this.showJunior = true;
                            _this.searchId = data.value;
                            var serialize = $('.form1').serializeArray();
                            for(var x = 0;x<serialize.length; x++){
                                if(serialize[x].name === 'date'){
                                    serialize[x].value = _this.date;
                                }
                                jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                            }
                            _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                            jointUrl='';
                        }else{
                            _this.selectedPositionAll.selectedPosition1 = [];
                            _this.selectedPositionAll.selectedPosition2 = [];
                            _this.selectedPositionAll.selectedPosition3 = [];
                            _this.selectedPositionAll.selectedPosition4 = [];
                            _this.selectedPositionAll.selectedPosition5 = [];
                            _this.selectedPositionAll.selectedPosition6 = [];
                        }
                    });
                    form.on('select(selectedPosition2)',function(data){
                        table.reload('idTest',{
                            url: url,
                            where:{
                                id:data.value,
                                type:'',
                                yufang:'',
                                visit: ''
                            },done: function (res) {//渲染完成回调，获取总条目数。
                                _this.count = res.count;
                                _this.selectedPositionAll.selectedPosition3 = [];
                                if(res.number.length !==0){
                                    for(var x in res.number){
                                        _this.selectedPositionAll.selectedPosition3.push({
                                            id:res.number[x].id,
                                            name:res.number[x].name,
                                        });
                                        _this.selectedPositionAll.selectedPosition4 = [];
                                        _this.selectedPositionAll.selectedPosition5 = [];
                                        _this.selectedPositionAll.selectedPosition6 = [];
                                        _this.$nextTick(function(){
                                            form.render();
                                        })
                                    }
                                }else{
                                    _this.selectedPositionAll.selectedPosition3 = [];
                                    _this.selectedPositionAll.selectedPosition4 = [];
                                    _this.selectedPositionAll.selectedPosition5 = [];
                                    _this.selectedPositionAll.selectedPosition6 = [];
                                }

                            }
                        });
                        _this.showTool = false;
                        _this.searchId = data.value;
                        var serialize = $('.form1').serializeArray();
                        for(var x = 0;x<serialize.length; x++){
                            if(serialize[x].name === 'date'){
                                serialize[x].value = _this.date;
                            }
                            jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                        }
                        _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                        jointUrl='';
                    });
                    form.on('select(selectedPosition3)',function(data){
                        table.reload('idTest',{
                            url: url,
                            where:{
                                id:data.value,
                                type:'',
                                yufang:'',
                                visit: ''
                            },done: function (res) {//渲染完成回调，获取总条目数。
                                _this.count = res.count;
                                _this.selectedPositionAll.selectedPosition4 = [];
                                if(res.number.length !==0){
                                    for(var x in res.number){
                                        _this.selectedPositionAll.selectedPosition4.push({
                                            id:res.number[x].id,
                                            name:res.number[x].name,
                                        });
                                        _this.selectedPositionAll.selectedPosition5 = [];
                                        _this.selectedPositionAll.selectedPosition6 = [];
                                        _this.$nextTick(function(){
                                            form.render();
                                        })
                                    }
                                }else{
                                    _this.selectedPositionAll.selectedPosition4 = [];
                                    _this.selectedPositionAll.selectedPosition5 = [];
                                    _this.selectedPositionAll.selectedPosition6 = [];
                                }

                            }
                        });
                        _this.showTool = false;
                        _this.searchId = data.value;
                        var serialize = $('.form1').serializeArray();
                        for(var x = 0;x<serialize.length; x++){
                            if(serialize[x].name === 'date'){
                                serialize[x].value = _this.date;
                            }
                            jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                        }
                        _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                        jointUrl='';
                    });
                    form.on('select(selectedPosition4)',function(data){
                        table.reload('idTest',{
                            url: url,
                            where:{
                                id:data.value,
                                type:'',
                                yufang:'',
                                visit: ''
                            },done: function (res) {//渲染完成回调，获取总条目数。
                                _this.count = res.count;
                                _this.selectedPositionAll.selectedPosition5 = [];
                                if(res.number.length !==0){
                                    for(var x in res.number){
                                        _this.selectedPositionAll.selectedPosition5.push({
                                            id:res.number[x].id,
                                            name:res.number[x].name,
                                        });
                                        _this.selectedPositionAll.selectedPosition6 = [];
                                        _this.$nextTick(function(){
                                            form.render();
                                        })
                                    }
                                }else{
                                    _this.selectedPositionAll.selectedPosition5 = [];
                                }

                            }
                        });
                        _this.showTool = false;
                        _this.searchId = data.value;
                        var serialize = $('.form1').serializeArray();
                        for(var x = 0;x<serialize.length; x++){
                            if(serialize[x].name === 'date'){
                                serialize[x].value = _this.date;
                            }
                            jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                        }
                        _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                        jointUrl='';
                    });
                    form.on('select(selectedPosition5)',function(data){
                        table.reload('idTest',{
                            url: url,
                            where:{
                                id:data.value,
                                type:'',
                                yufang:'',
                                visit: ''
                            },done: function (res) {//渲染完成回调，获取总条目数。
                                _this.count = res.count;
                                _this.selectedPositionAll.selectedPosition6 = [];
                                if(res.number.length !==0){
                                    for(var x in res.number){
                                        _this.selectedPositionAll.selectedPosition6.push({
                                            id:res.number[x].id,
                                            name:res.number[x].name,
                                        });
                                        _this.$nextTick(function(){
                                            form.render();
                                        })
                                    }
                                }else{
                                    _this.selectedPositionAll.selectedPosition6 = [];
                                }

                            }
                        });
                        _this.showTool = false;
                        _this.searchId = data.value;
                        var serialize = $('.form1').serializeArray();
                        for(var x = 0;x<serialize.length; x++){
                            if(serialize[x].name === 'date'){
                                serialize[x].value = _this.date;
                            }
                            jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                        }
                        _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                        jointUrl='';
                    });
                    form.on('select(selectedPosition6)',function(data){
                        table.reload('idTest',{
                            url: url,
                            where:{
                                id:data.value,
                                type:"",
                                yufang:"",
                                visit: ""
                            },done: function (res) {//渲染完成回调，获取总条目数。
                                _this.count = res.count;
                            }
                        });
                        _this.showTool = false;
                        _this.searchId = data.value;
                        var serialize = $('.form1').serializeArray();
                        for(var x = 0;x<serialize.length; x++){
                            if(serialize[x].name === 'date'){
                                serialize[x].value = _this.date;
                            }
                            jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                        }
                        _this.derive = url+"&simple=1&id="+data.value+jointUrl+_this.search;
                        jointUrl='';
                    });
                })
            },
            form3(){
                var _this = this,
                    url = this.urls.client.follow;//提交数据
                    // url1 = this.urls.client.search;//表格加载
                layui.use(['form','table'],function() {
                    var form = layui.form;
                    var table = layui.table;
                    form.on('select(select1)',function(data){
                         // console.log(_this.values,data.value);
                        $.post(url,{id:_this.values.id,status:data.value},function(res){
                            // console.log(res)
                            layer.open({
                                content: '<div style="padding: 20px 100px;">'+ res.msg +'</div>'
                                ,shade: 0
                            });
                        });
                        table.reload('idTest');
                    })
                })
            },
            formTable() {
                var _this = this,
                    url = this.urls.client.search;
                layui.use(['table','form'], function () {
                    var table = layui.table;
                    var form = layui.form;
                    //实例
                    _this.$nextTick(function(){
                    table.render({
                        elem: '#table'
                        , id: 'idTest'
                        , height: '491'
                        , limit: 10
                        ,method:"POST"
                        , url: url //数据接口
                        , page: {theme:'#cd1f5c'} //开启分页
                        , cols: [[ //表头
                            {field:'numbers', title: '序号',type:'numbers',width:80}
                            , {field: 'name', title: '用户姓名',}
                            , {field: 'telephone', title: '电话',}
                            , {field: 'building', title: '意向楼盘',}
                            , {field: 'time', title: '录入时间',minWidth:'175'}
                            , {field: 'date', title: '跟进时间',minWidth:'175'}
                            , {field: 'account_id', title: '录入负责人'}
                            , {field: 'account_id1', title: '录入个人'}
                            , {title: '操作', align: 'center', toolbar: '#barDemo', fixed: 'right'} //这里的toolbar值是模板元素的选择器}
                        ]]
                        ,done:function(res, curr, count){//渲染完成回调，获取总条目数。
                            _this.count = count;
                        }
                    });
                    })
                    //监听工具条事件
                    table.on('tool(text)', function (obj) {
                        var data = obj.data //获得当前行数据
                            , layEvent = obj.event; //获得 lay-event 对应的值
                        $("#select1").val(data.status);
                        form.render();
                        if(layEvent === 'edit'){
                            _this.values = obj.data;
                            _this.follow_info = _this.values.follow_info.length === 0;
                            _this.deal_info = (_this.values.deal_info.length === 0);
                            _this.transfer_info = (_this.values.transfer_info === null);
                            _this.notes = (_this.values.notes === '' || _this.values.notes === null);
                            _this.visit = (_this.values.visit === null);
                            layer.open({
                                type: 1,
                                area:['500px','600px'],
                                title:['基本信息'],
                                content: $('#edit'),
                                cancel:function(){
                                    $('#edit').hide();
                                }
                            });
                        }
                    });
                });
            }
        },
        methods: {
            searchPush() {
                var key = this.search,
                    _this = this,
                    url = this.urls.client.search;
                layui.use(['table'], function () {
                    var table = layui.table,
                        serialize = $('.form1').serialize();
                    table.reload('idTest', {
                        url: url,
                        where: {
                            key: key
                        },
                        done(res) {
                            _this.count = res.count;
                            _this.derive = url+"&simple=1&"+serialize+"&key="+key;
                        }
                    });
                })
            },
            day() {
                var _this = this;
                var url = this.urls.client.search;
                var jointUrl='';
                layui.use(['layer', 'table',], function () {
                    var layer = layui.layer;
                    var table = layui.table;
                    table.reload('idTest', {
                        url: url,
                        where: {
                            yufang: 'yufang',
                            type: '',
                            visit: '',
                            id:_this.searchId
                        }, done(res) {
                            _this.count = res.count;
                            var serialize = $('.form1').serializeArray();
                            if(res.data.length === 0){
                                _this.isShowBtn = true;
                            }else{
                                _this.isShowBtn = false;
                            }
                            for(var x = 0;x<serialize.length; x++){
                                if(serialize[x].name === 'date'){
                                    serialize[x].value = _this.date;
                                }
                                jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                            }
                            _this.derive = url+"&simple=1&yufang=yufang"+jointUrl+_this.search+"&id="+_this.searchId;
                            jointUrl='';
                        }

                    });
                });
            },
            del() {
                var _this = this;
                var url = this.urls.client.search;
                layui.use(['table'], function () {//搜索直接更新表格数据
                    var table = layui.table;
                    table.reload('idTest', {
                        url: url,
                        where: {
                            type: '',
                            yufang: '',
                            visit: '',
                            id:_this.searchId
                        }, done(res) {
                            _this.count = res.count;
                            _this.isShowBtn = false;
                            _this.derive = url+"&simple=1&key="+_this.search+"&id="+_this.searchId;
                        }
                    });
                });
            },
            imgShow(e) {
                layui.use('layer', function () {
                    layer.open({
                        type: 1,
                        area: ['500px', '600px'],
                        title: ['凭证详情'],
                        content: '<img src=' + e.target.src + ' />',
                        // cancel:function(){
                        //     $('#edit').hide();
                        // }
                    });
                })
            },
            emptyAll(){
                var _this = this;
                var url = this.urls.client.search;
                var serialize = $('.form1').serializeArray();
                var jointUrl='';
                _this.selectedPositionAll.selectedPosition1 = [];
                _this.selectedPositionAll.selectedPosition2 = [];
                _this.selectedPositionAll.selectedPosition3 = [];
                _this.selectedPositionAll.selectedPosition4 = [];
                _this.selectedPositionAll.selectedPosition5 = [];
                _this.selectedPositionAll.selectedPosition6 = [];
                layui.use(['table','form'], function () {
                    var table = layui.table;
                    var form = layui.form;
                    table.reload('idTest',{
                        url: url,
                        where:{
                        },done: function (res) {//渲染完成回调，获取总条目数。
                            _this.count = res.count;
                            _this.$nextTick(function(){
                                form.render();
                            })
                        }
                    });
                    _this.showTool = true;
                    for(var x = 0;x<serialize.length; x++){
                        // c[serialize[x].name] = serialize[x].value;//对象添加删选数据
                        if(serialize[x].name === 'date'){
                            serialize[x].value = _this.date;
                        }
                        jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                    }
                    _this.derive = url+"&simple=1&visit=1"+jointUrl+_this.search;
                    _this.searchId="";
                    jointUrl='';
                })
            },
            Visit(){
                var _this = this;
                var url = this.urls.client.search;
                var serialize = $('.form1').serializeArray();
                var jointUrl='';
                // var c={};
                layui.use(['layer', 'table',], function () {
                    var layer = layui.layer;
                    var table = layui.table;
                    table.reload('idTest', {
                        url: url,
                        where: {
                            type: '',
                            yufang: '',
                            visit: 1,
                            id:_this.searchId,
                        }, done(res) {
                            _this.count = res.count;
                            if(res.data.length === 0){
                                _this.isShowBtn = true;
                            }else{
                                _this.isShowBtn = false;
                            }
                            for(var x = 0;x<serialize.length; x++){
                                // c[serialize[x].name] = serialize[x].value;//对象添加删选数据
                                if(serialize[x].name === 'date'){
                                    serialize[x].value = _this.date;
                                }
                                jointUrl+='&'+serialize[x].name+'='+serialize[x].value;
                            }
                            _this.derive = url+"&simple=1&visit=1"+jointUrl+_this.search+"&id="+_this.searchId;
                            jointUrl='';
                        }

                    });
                });
            }
        }
    }
</script>
<style scoped lang="less">
    @import "../../static/css/style.less";
    .add {
       label{
           line-height: 40px;
           text-align: left;
       }
        .layui-inline, select, .layui-form-select .layui-input {
            min-width: 140px !important;
            height: 40px !important;
            color: @c6 !important;
        }
        .layui-input-inline {
            vertical-align: initial;
        }
        .layui-inline{
            margin-bottom: 10px;
        }
        form{
            >div{
                margin-right: 8px;
            }
        }
    }
    .main{
        background-color: @cf;
        padding: 20px;
        .bs(0 0 5px #ccc);
        margin-top: 20px;
        .search {
            width: 100%;
            height: 40px;
            line-height: 30px;
            padding: 5px 20px;
            background-color: #ededed;
            .pr;
            > span, > .form2 {
                .fl;
            }
            > .form2 {
                .df;
                button{
                    margin-right: 15px;
                    cursor: pointer;
                }
                >div:last-child{
                    .pa;
                    right: 20px;
                }
                .layui-form-item {
                    .pr;
                    .layui-input-inline {
                        width: 120px;
                        height: 30px !important;
                        margin: 0 10px 0 0;
                        input {
                            .br(2px 0 0 2px);
                            height: 30px !important;
                        }
                    }
                    label {
                        width: 40px;
                        height: 30px;
                        .pa;
                        top: 0;
                        right: 0;
                        cursor: pointer;
                        .br(0 2px 2px 0);
                        .blg(to right, #cd1f5c, #e11e27);
                        i {
                            width: 15px;
                            height: 15px;
                            display: inline-block;
                            .pa;
                            .cm;
                            .bud("../../static/images/search.svg", center center, 100% 100%);
                        }
                    }
                }
                .layui-form-item:last-child{
                    .layui-input-inline {
                    width: 220px;
                }

                }
            }

        }
    }
    #edit{
        width: 100%;
        height: 100%;
        padding:15px 20px;
        display: none;
        form{
            width: 100%;
            height: 100%;
            label{
                width: 120px;
                height: 40px;
                line-height: 40px;
                padding-right:20px;
            }
            .layui-form-item {
                margin-bottom: 15px;
                clear: both;
                .title{
                    background: #e3e3e3;
                    color: #666;
                    padding:5px 10px;
                }
                .edit-text{
                    width: 100%;
                    max-height: 250px;
                    overflow: auto;
                    >div{
                        padding:20px 0;
                        border-bottom: 1px solid #eee;
                        p{
                            line-height: 30px;
                            .df;
                            span:first-child{
                                width: 85px;
                            }
                            span:last-child{
                                width: 341px;
                            }
                        }
                    }

                }
                .layui-inline{
                    width: 49%;
                    margin-right: 0;
                }
                .transfer_info{
                    height: auto;
                }
                img{
                    width: 48%;
                    padding: 10px;
                    margin: 10px 1% 0;
                    cursor: pointer;
                }
            }
            /*.layui-object{*/
                /*.layui-form-label{*/
                    /*width: 90px;*/
                    /*text-align: left;*/
                    /*padding:0 0 0 20px;*/
                /*}*/
                /*.layui-input-inline{*/
                    /*width: 100px;*/
                    /*height: 40px;*/
                /*}*/
                /*.object{*/
                    /*width: 150px;*/
                /*}*/
            /*}*/
        }
        button{
            .blg(to right,#cd1f5c,#e11e27);
        }

    }
</style>